{include file="header.tpl"}
{if $core->nodePartOf("news/add")}{include file="news_add.tpl"}
{elseif $core->nodePartOf("news/edit")}{include file="news_edit.tpl"}
{elseif $core->nodePartOf("news/delete")}{include file="news_delete.tpl"}
{else}
<div class="page_header">Latest News</div>
{assign var="news" value=$core->database->get_news()}
{if !$news}
No news items to display {if $core->session->isLoggedIn() == 1}{if $smarty.session.userlevel >= $smarty.const.USER_MODERATOR}- <a href="./?n=news/add">Add News</a>{/if}{/if}
{else}
<div class="news">{section name=news loop=$news} 
<p><h1>{$news[news].title}</h1> by {$core->database->getInfo("username","users","userid",$news[news].userid)} on {$news[news].timestamp|date_format}<br />
{$news[news].body}<br />
<a href="./?n=comments&id={$news[news].postid}">{$news[news].comments} Comment{if ($news[news].comments > 1)}s{/if}{if ($news[news].comments == 0)}s{/if}</a>
{if $core->session->isLoggedIn() == 1}
{if $smarty.session.userlevel >= $smarty.const.USER_MODERATOR}- <a href="./?n=news/edit&id=&id={$news[news].postid}">Edit</a> - <a href="./?n=news/delete&id={$news[news].postid}">Delete</a>{/if}
{/if}</p>
{/section}
</div>
{/if}
{/if}
{include file="footer.tpl"}